package com.fqgj.sentry.policy.dao.impl;

import com.fqgj.common.base.AbstractBaseMapper;
import com.fqgj.sentry.policy.dao.PcRuleColumnDao;
import com.fqgj.sentry.policy.entity.PcRuleColumnEntity;
import com.fqgj.sentry.policy.entity.PcRuleEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * User: liupengpeng
 * Date: 2017-07-25
 * Time: 15:46:14.858
 */

@Repository
public class PcRuleColumnDaoImpl extends AbstractBaseMapper<PcRuleColumnEntity> implements PcRuleColumnDao {

    @Override
    public Integer deleteByRuleId(Long ruleId) {
        return getSqlSession().delete(getStatement("deleteByRuleId"), ruleId);
    }

    @Override
    public void deleteByRuleIds(List<Long> ruleIds) {
        Map params = new HashMap();
        params.put("ruleIds", ruleIds);
        getSqlSession().delete(getStatement("deleteByRuleIds"), params);
    }

    @Override
    public Integer updateDeleteByRuleId(Long ruleId) {
        return getSqlSession().delete(getStatement("updateDeleteByRuleId"), ruleId);
    }

    @Override
    public List<PcRuleColumnEntity> selectByColumnId(Long columnId) {
        return getSqlSession().selectList(getStatement("selectOneByColumnId"), columnId);
    }

    @Override
    public List<PcRuleColumnEntity> findByRuleId(Long ruleId) {
        return getSqlSession().selectList(getStatement("findByRuleId"), ruleId);
    }

    @Override
    public List<PcRuleColumnEntity> findByRuleIds(List<Long> ruleIds) {

        Map params = new HashMap();
        params.put("ruleIds", ruleIds);
        return getSqlSession().selectList(getStatement("findByRuleIds"), params);
    }
}